package com.leetcode.bit;

/**
 * @author Dennis Li
 * @date 2020/7/21 15:16
 */
public class IsPowerOfTwo_231 {

    public static boolean isPowerOfTwo(int n) {
        // 2的幂次方只有1个1
        return n > 0 && Integer.bitCount(n) == 1;
    }
}
